package task.snake.model;

/**
 * Class describes a cell of playing area. Fields up, down, left and right
 * associated with directions where creature can move to from this cell.
 * 
 * @author Nadezhda Makarkina
 * 
 */
public class Cell {
	// direction is free if variable is false
	private boolean up = false;
	private boolean down = false;
	private boolean left = false;
	private boolean right = false;
	private Creature creature;

	/**
	 * Initializes a newly created cell object.
	 */
	public Cell() {
	}

	/**
	 * Returns the state of up field.
	 * 
	 * @return
	 */
	public boolean getUp() {
		return up;
	}

	/**
	 * Returns the state of down field.
	 * 
	 * @return
	 */
	public boolean getDown() {
		return down;
	}

	/**
	 * Returns the state of left field.
	 * 
	 * @return
	 */
	public boolean getLeft() {
		return left;
	}

	/**
	 * Returns the state of right field.
	 * 
	 * @return
	 */
	public boolean getRight() {
		return right;
	}

	/**
	 * Returns true if all four fields (up, down, left ,right) are true.
	 * 
	 * @return
	 */
	public boolean isAllDirectionsBusy() {
		return right & left & up & down;
	}

	/**
	 * Sets the state of up field.
	 * 
	 * @param b
	 */
	public void setUp(boolean b) {
		up = b;
	}

	/**
	 * Sets the state of down field.
	 * 
	 * @param b
	 */
	public void setDown(boolean b) {
		down = b;
	}

	/**
	 * Sets the state of left field.
	 * 
	 * @param b
	 */
	public void setLeft(boolean b) {
		left = b;
	}

	/**
	 * Sets the state of right field.
	 * 
	 * @param b
	 */
	public void setRight(boolean b) {
		right = b;
	}

	/**
	 * Returns the creature which is positioned on this cell.
	 * 
	 * @return
	 */
	public Creature getCreature() {
		return creature;
	}

	/**
	 * Sets the cell busy by the creature.
	 * 
	 * @param creature
	 */
	public void setCreature(Creature creature) {
		this.creature = creature;
	}
}
